//
//  PaperItemTitleCell.swift
//  Exam-iOS
//
//  Created by 李胜锋 on 2018/3/9.
//  Copyright © 2018年 李胜锋. All rights reserved.
//

import Foundation
import UIKit

/// 试题标题
class PaperItemTitleCell: UITableViewCell {
    //    var type:PaperItemType = .radio
    
    var contentLabel:UILabel!
    
    public func set(type: PaperItemType?, content: String?, score: Double?) {
        
        var preStr = ""
        
        if type != nil {
            switch type! {
            case .radio:
                preStr = "单选题"
            case .multiSelect:
                preStr = "多选题"
                
            case .trueOrFalse:
                preStr = "判断题"
                
            case .shortAnswer:
                preStr = "简答题"
                
            case .analysis:
                preStr = "综合分析题"
                
            case .in_trayTest:
                preStr = "公文筐测验"
            
            case .calculation:
                preStr = "计算题"
            
            }
        }
        
        let text = String(format: "【%@-%g分】%@", preStr, score ?? 0, content ?? "")
        contentLabel.lsf_htmlParagraphTextAndFitSize(text: text,
                                                     width: k_screen_width - 20,
                                                     firstLineHeadIndent: 0)
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        setup()
    }
    
    
    private func setup() {
        self.backgroundColor = .clear
        
        contentLabel = UILabel.init()
        contentLabel.numberOfLines = 0
        contentLabel.font = UIFont.systemFont(ofSize: 15)
        contentView.addSubview(contentLabel)
        
        contentLabel.snp.makeConstraints { (make) in
            make.edges.equalTo(UIEdgeInsetsMake(20, 10, 10, 10))
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
